/*
 * Copyright (C), 2013-2015, 韩伟
 * FileName: QuartzJobFactory.java
 * Author:   yyt
 * Date:     2015年5月8日 下午2:04:40
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.cango.framework.base.job;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.cango.qutz.web.entity.ScheduleJob;
import org.springframework.util.StringUtils;

/**
 * 〈一句话功能简述〉<br>
 * 定时任务执行 实现JOB方法
 *
 * @author yyt
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public class QuartzJobFactory implements Job {

    /**
     * log
     */
    private final Log log = LogFactory.getLog(QuartzJobFactory.class);

    /**
     * myJob
     */
    private JobExecute myJob = null;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        ScheduleJob job = (ScheduleJob) context.getMergedJobDataMap().get("quartzScheduler");
        this.myJob = (JobExecute) context.getMergedJobDataMap().get("myJob");
        Object executeType = context.getMergedJobDataMap().get("executeType");
        if(null != executeType){
            job.setExecuteType(executeType.toString());
        }
        log.debug("----任务名称: [" + job.getJobName() + "]; 执行方法："
                + job.getMethodName());
        this.myJob.execute(job);
    }

}
